#include "ParseSymbolsTest.h"
#include "../Parsing/Parsing.h"
#include "../Defines.h"
#include "../SQLInterface/Tuple.h"
#include "../SQLInterface/Database.h"
#include "../Tools/linked_list.h"
#include "../Tools/Sort.h"
#include <stdio.h>
#include <stdlib.h>

result_type parse_symbols_test(void)
{
    /*char** symbolList = null;
    int length = 0;
    int result;
    result = parse_symbols(symbolList, &length);*/
    return UNDEFINED;
}

result_type parse_symbols_spot_test(void)
{
    char** symbolList = NULL;
    int length;
    int i = 0;
    FILE* fp;
    result_type result;

    fp = fopen("parse_symbols.txt", "w+");
    result = parse_symbols(&symbolList, &length);
    switch(result)
    {
        case SUCCESS:
            //TODO: this needs to be output to file or something...
            for(i = 0; i < length; i++)
            {
                fprintf(fp, symbolList[i]);
                fprintf(fp, "\n");
            }
            break;
        default:
            return result;
    }
    fclose(fp);

    return SPOT_CHECK;
}


result_type parse_html_simple(void)
{
    node_t* list = init_list((void*)NULL);//empty head...

    // TODO: manage memory

    return parse_html_table("Tests/A3100.html", list, "A");
}

// was using to temporary test stuff...
result_type parse_html_spot_test(void)
{
    FILE* fp;
    node_t* list = init_list((void*)NULL);//empty head...
    int index;

    fp = fopen("parse_html.txt","w+");

    parse_html_table("Tests/A0.html", list, "A");
    parse_html_table("Tests/A3100.html", list, "A");

    for(list = list->next; list != NULL;list = list->next)
    {
        for(index = 0; index < STOCK_DATA_PARAMS; index++)
        {
            fprintf(fp, "%s", (char*)(((tuple_t*)(list->element))->params[index]));
            fprintf(fp, " ");
            //printf("%s", (((tuple_t*)(list->element))->params[index]));
            //printf(" ");
        }
        fprintf(fp, "\n");
        //printf("\n");
    }

    fclose(fp);
    // TODO: manage memory

    return SPOT_CHECK;
}

result_type date_conversion_test(void)
{
    char buffer[100] = "Apr 23, 2012";

    //printf(webDateToSqlDate(buffer));

    return SUCCESS;
}
